package com.controller;

import com.entity.Emp;
import com.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class EmpController {
    @Autowired
    private EmpService empService;

    @RequestMapping("/")
    public String getAll(@RequestParam(defaultValue = "1") int pageNum,
                         @RequestParam(required = false, defaultValue = "2") int pageSize,
                         Model model) {
        List<Emp> result = empService.getAll(pageNum, pageSize);
        model.addAttribute("list", result);
        return "index";

    }

    @RequestMapping("/txt")
    public String testTx() {
        empService.testTx();
        return "index";
    }
}
